<?php
class WebUser extends RWebUser{

	public function init()
	{
		parent::init();
		if (!Yii::app()->user->isGuest)
		{
			app()->theme = 'admin_cup';
		}
		else 
		{
			app()->theme = 'cup';
		}
	}
	
	public function getModel()
    {
        return Yii::app()->getSession()->get('model');
    }
 
    public function login($identity, $duration)
    {
        parent::login($identity, $duration);
        Yii::app()->getSession()->add('model', $identity->getModel());
    }

    public function logout($destroySession= true,$keyMessage='')
    {
    	//$keyMessage = ($keyMessage != '')? '/'.$keyMessage :'';
    	//$this->loginUrl = array('/' . $this->_realestate_codename .  $this->loginUrl[0] . $keyMessage );
    	parent::logout($destroySession);
        // I always remove the session variable model.
        //Yii::app()->getSession()->remove('model');
    }
    
 
}